﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Quartz;
using YouWei.Infrastructure.Service;
using YouWei.Utility.Logging;

namespace ServiceContainer.Jobs
{
    /// <summary>
    /// 卡片状态同步更新,暂时没有使用..逻辑还需要考虑
    /// </summary>
    public class SmsCardStatusSyncJob:IJob
    {
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                DoWork();
            }
            catch (Exception ex)
            {
                Log4netLog.Error(101,context.JobDetail.Key + "作业出现异常,异常信息为：" + ex);
            }
        }

        public void DoWork()
        {
            var svPort=new port_infoService();
            var svCard=new SmsCardService();
            var listCurrentPorts = svPort.GetCurrentRunPorts();

            //先禁用所有卡片，再更新目前正在运行的卡片状态
            svCard.DisabledAllSmsCards();
            foreach (var port in listCurrentPorts)
            {
               svCard.SafeInsertCard(port.PhoNum);
            }
            

        }
    }
}
